<template>
  <div class="report-detail">
    <!-- <showDicom :needUploadBtn="false" :fileList="fileList"/> -->
    <el-form ref="form" :model="form" label-width="80px" style="margin-left:100px;" >



       <el-row>
        <el-col :span="12">
          <el-form-item label="诊断医生" prop='doctor_opinion'>
            <el-input v-model="form.doctorName"  readonly=true></el-input>
          </el-form-item>
        </el-col>
    
      </el-row>
      <el-row>
            <el-col :span="12">
         <el-form-item label="诊断时间" >
            <el-input v-model="form.submitDate" readonly=true></el-input>
          </el-form-item>
        </el-col>
      </el-row>
       <el-row>
         <el-col :span="12">
          <el-form-item label="影像描述" prop="dcm_account" >
            <el-input type="textarea" v-model="form.dcm_account"  :autosize="{ minRows: 4}" readonly=true></el-input>
          </el-form-item>
        </el-col>
       
      </el-row>
      <el-row>
         <el-col :span="12">
          <el-form-item label="诊断说明" prop="doctor_opinion" >
            <el-input type="textarea" v-model="form.doctor_opinion"  :autosize="{ minRows: 4}" readonly=true></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-button type="success"   @click="print" style="cursor:pointer;">下载报告</el-button>
     
    </el-form>
        <ReportExport :info="form" :pat='pat' :date='printDate'/>
  </div>
</template>

<script>
import showDicom from "../../components/showDicom/showDicom_New"
import { getPdf } from "@/utils"
import ReportExport from "./ReportExport"

export default {
  components: {
    showDicom,
    ReportExport
  },
  name: "upload",
  data () {
    return {
      pat:'',
      printDate:'',
      date:'',
      fileList: [],
      id: this.$route.query.id,
      form: {
        doctor_opinion: "",
        NAME: "",
        region: "",
        birthday: "",
        date: "",
        delivery: false,
        type: [],
        resource: "",
        desc: ""
      },

      imageUrl: "",
      dialogImageUrl: "",
      dialogVisible: false
    }
  },
  methods: {
    async getDcm () {
      if (this.id) {
        const result = await this.$request.getReport({
          id: this.id
        })
        if (result.code === 200) {
          console.log(result)
          this.fileList = result.urls
          this.form = result.data.info
          this.pat=result.data.patientAccounts[0]
          console.log(this.form)
         
        } else {
          this.$message.error(result.msg)
        }
      }
    },
    // print () {
    //   // getPdf(".report-detail", "报告详情")
      
    // }
     getDate(){
       let date = new Date();
       console.log(date)
       let y=date.getFullYear(),
           m=date.getMonth()+1,
           d=date.getDate(),
           h=date.getHours(),
           m1=date.getMinutes(),
           s=date.getSeconds();


    this.printDate=y+'/'+m+'/'+d+' '+h+':'+m1+':'+s
    console.log(this.printDate)

   },
      print() {
      this.getDate()
      console.log('ReportExport')
      setTimeout(function(){ 
        const report = document.querySelector(".report")
      report.style.display = "block"
      getPdf(".report", "报告")
      report.style.display = "none"},500);
     
    }
  },
  mounted () {
    this.getDcm()
    this.getDate
  }
}
</script>

<style lang="scss">
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
h3 {
  margin: 55px 0 20px;
  font-weight: 400;
  color: #1f2f3d;
  font-size: 22px;
}
p {
  font-size: 14px;
  color: #5e6d82;
  line-height: 1.5em;
}
</style>
